package cn.itcast.web.servlet;


import cn.itcast.service.UserService;
import cn.itcast.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
import java.io.IOException;


@WebServlet("/settlementServlet")
public class settlementServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setCharacterEncoding("utf-8");//数据编码格式设置
        response.setContentType("application/json;charset=utf-8");
        String data=null;

        String foodList = request.getParameter("shp");  //获取 foodList对应的json字符串
        String user=request.getParameter("user");

        String len=request.getParameter("len");
        String shou=request.getParameter("shou");
        UserService service=new UserServiceImpl();
            int num= service.addSop(foodList,user,len,shou);
            if (num>=1){
                data="{\"message\":\"true\"}";
                response.getWriter().append(data);
            }else {
                data="{\"message\":\"false\"}";
                response.getWriter().append(data);
            }




    }
}
